/*
 * Created on 28-ago-2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package core.loaders;

import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.Toolkit;

import core.ImageLibrary;

public class ImageLoader {
	Toolkit toolkit;
	MediaTracker tracker;

	public ImageLoader(ImageLibrary ilib) {
		toolkit = ilib.getToolkit();
		tracker = new MediaTracker(ilib);
	}

	public Image load(String image) {
		Image img = toolkit.createImage(image);
		tracker.addImage(img, 0);
		try {
			tracker.waitForAll();
		} catch (Exception e) {
			System.out.println(":: Error loading image :: \n" + e);
		}
		tracker.removeImage(img);
		return img;
	}
}
